const Router = require('koa-router')

const {verifyAuth, verifyPermission} = require('../middleware/auth_middleware')
const {create, detail, list, update, remove, addLabels, fileInfo} = require('../controller/moment_controller')
const {verifyLabel} = require('../middleware/label_middleware')

const momentRouter = new Router({prefix:'/moment'})

// 发动态
momentRouter.post('/', verifyAuth, create)

// 查询多条动态
momentRouter.get('/', list)

// 获取某一条动态
momentRouter.get('/:momentId', detail)

// 修改动态内容
momentRouter.patch('/:momentId', verifyAuth, verifyPermission('moment'), update)

// 删除动态
momentRouter.delete('/:momentId', verifyAuth, verifyPermission('moment'), remove)

// 给动态加标签
momentRouter.post('/:momentId/labels', verifyAuth, verifyPermission('moment'), verifyLabel, addLabels)

momentRouter.get('/images/:filename', fileInfo)

module.exports = momentRouter

